﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharpTRI
{
    class Vec3D
    {
	    public float X{get;set;}
        public float Y{get;set;}
        public float Z{get;set;}

        public override bool Equals(object obj)
        {
            const float eps = .0000001f;
            Vec3D other = (Vec3D)obj;
            return (Math.Abs(X - other.X) < eps) && (Math.Abs(Y - other.Y) < eps) && (Math.Abs(Z - other.Z) < eps);

        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

	    public static bool operator ==(Vec3D left, Vec3D right)
	    {
            return left.Equals(right);
	    }

	    public static bool operator !=(Vec3D left, Vec3D right)
	    {
            return !left.Equals(right);
	    }

        public Vec3D()
            :this(0,0,0)
        {
	    }

        public Vec3D(float x, float y, float z)
	    {
            X = x;
            Y = y;
            Z = z;
	    }

        public Vec3D(Vec3D first, Vec3D second)
            :this(second.X - first.X, second.Y - first.Y, second.Z - first.Z)
	    {
	    }
        
	    public static Vec3D operator + (Vec3D left, Vec3D right)
	    {
		    return new Vec3D(left.X + right.X, left.Y + right.Y, left.Z + right.Z);
	    }

	    public float Lenght()
	    {
		    return (float)Math.Sqrt(X*X + Y*Y + Z*Z);
	    }

        public override string ToString()
        {
            return "X: " + X + " Y: " + Y + " Z: " + Z;
        }
    };

    class Color
    {
        public int R { get; set; }
        public int G { get; set; }
        public int B { get; set; }

	    public Color(int r, int g, int b)
	    {
            R = r;
            G = g;
            B = b;
	    }

        public Color()
		    :this(0,0,0)
	    {
	    }

        public static Color Green
        {
            get
            {
                return new Color(0, 255, 0); 
            } 
        }

        public static Color Red
        {
            get
            {
                return new Color(255, 0, 0);
            }
        }

        public static Color Orange
        {
            get
            {
                return new Color(255, 128, 64);
            }
        }
    }
}
